/** @format */

function getResult(title: string, isSuccess: boolean): Promise<string> {
    return new Promise((resolve, reject) => {
        if (isSuccess) {
            console.log(`IN[${title}]Success`);
            resolve(`OUT[${title}]Success`);
        } else {
            console.log(`IN[${title}]Unsuccessful`);
            reject(new Error(`OUT[${title}]Unsuccessful`));
        }
    });
}

const promise1: Promise<string> = getResult('Promise1', true);
// promise1
//     .then((value: string): void => {
//         console.log(value);
//     })
//     .catch((error: Error) => {
//         console.log(error);
//     })
//     .finally(() => {
//         console.log('Promise1 Finally');
//     });

const promise2: Promise<string> = getResult('Promise2', false);
// promise2
//     .then((value: string): void => {
//         console.log(value);
//     })
//     .catch((error: Error) => {
//         console.log(error);
//     })
//     .finally(() => {
//         console.log('Promise2 Finally');
//     });

promise1.then((value: string): void => {
    console.log(value);
});

promise2.catch((error: Error) => {
    console.log(error);
})

promise1.finally(() => {
    console.log('Promise2 Finally');
});

console.log('Hello World！');
